#include <gtest/gtest.h>
#include <iostream>
#include <unordered_map>
#include <string>

// 全局事件测试
std::unordered_map<std::string, std::string> dict_map;
class HashTestEnv : public testing::Environment
{
public:
    virtual void SetUp() override
    {
        std::cout << "单元测试前，进行环境初始化！" << std::endl;
        dict_map.insert({"hello", "你好"});
        dict_map.insert({"world", "世界"});
        dict_map.insert({"apple", "苹果"});
    }

    virtual void TearDown() override
    {
        std::cout << "单元测试后，进行环境清理~" << std::endl;
    }
};

TEST(MapTest, find_test)
{
    auto it = dict_map.find("hello");
    ASSERT_NE(it, dict_map.end());
}

TEST(MapTest, size_test)
{
    ASSERT_GT(dict_map.size(), 0);
}

int main(int argc, char* argv[])
{
    testing::AddGlobalTestEnvironment(new HashTestEnv);
    testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();
    return 0;
}